﻿<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class canbonghihuu_Model extends Model {

    function __construct()
    {
        parent::__construct();
    }
    public function SELECT_CAN_BO_NGHI_HUU(){
        return $this->db->ExecuteCursor("BEGIN QLCB.SELECT_CAN_BO_NGHI_HUU(:CUR);END;",'CUR');
    }
    public function capnhat_nghihuu(){
        $P_MA_CAN_BO = get_post_var('hdn_item_id',0);
        $P_NGAY_NGHI_HUU = get_post_var('txt_NGAY_NGHI_HUU',0);
        $stmt = $this->db->PrepareSP("BEGIN QLCB.UPDATE_NGHI_HUU(:P_VAL,:P_MA_CAN_BO,:P_NGAY_NGHI_HUU);END;");
        $this->db->OutParameter($stmt,$P_VAL,'P_VAL');
        $this->db->InParameter($stmt,$P_MA_CAN_BO,'P_MA_CAN_BO');
        $this->db->InParameter($stmt,$P_NGAY_NGHI_HUU,'P_NGAY_NGHI_HUU');
        $chaythutuc = $this->db->Execute($stmt);
        if ($chaythutuc){
          if ($P_VAL == 'THANH_CONG'){
              $this->popup_exec_done();
          }else{
               echo $this->db->ErrorMsg();
              $this->popup_exec_fail('Không thể cập nhật');
               return;
          }
        }else{
            echo $this->db->ErrorMsg();
              $this->popup_exec_fail('Không thể cập nhật! Lỗi database');
            return;
        }
     }
}